<?php

namespace app\admin\controller;

use app\BaseController;
use app\lib\upload\Qiniu;

class Upload extends BaseController
{
    /* 上传文件 */
    public function file()
    {
        $file = request()->file('file');
        $savename = \think\facade\Filesystem::disk('public')->putFile( 'images', $file);
        if ($savename) {
            return show(config('status.success'), '图片上传成功', request()->domain() . '/storage/' . $savename);
        } else {
            return show(config('status.upload_error'), '图片上传失败');
        }
    }

    /* 上传图片 */
    public function image()
    {
        $file = request()->file('file');
        $savename = \think\facade\Filesystem::disk('public')->putFile( 'images', $file);
        if ($savename) {
            return show(config('status.success'), '图片上传成功', request()->domain() . '/storage/' . $savename);
        } else {
            return show(config('status.upload_error'), '图片上传失败');
        }
    }
}
